package org.wzy.springcloud.ribbon.rule;

import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.AbstractLoadBalancerRule;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 永远选择第一台服务器的规则
 *
 * @author wzy_h
 * @version 1.0
 * @date 21:19 2017/11/23
 * @description
 */
//public class FirstServerForeverRule extends AbstractLoadBalancerRule {
//    @Override
//    public void initWithNiwsConfig(IClientConfig iClientConfig) {
//
//    }
//
//    @Override
//    public Server choose(Object o) {
//        ILoadBalancer loadBalancer = getLoadBalancer();
//        List<Server> allServers = loadBalancer.getAllServers();
//        if (!CollectionUtils.isEmpty(allServers)) {
//            return allServers.get(0);
//        }
//        return null;
//    }
//}
